<div class="layui-form" lay-filter="layuiadmin-form-userform" style="margin: 0 auto;">



    <div class="layui-form-item">
        <label class="layui-form-label">车辆编号</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="agvId" value="{{ d.params.agvId || '' }}" lay-verify="" placeholder="请输入车辆编号" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">车型</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="type" value="{{ d.params.type || '' }}" lay-verify="" placeholder="请输入车型" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司名称</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <select name="companyId" id="sosoa" style="background-color: #F5F5F5;">
                </select>
            </script>
        </div>
    </div>
    <!-- <div class="layui-form-item">
        <label class="layui-form-label">公司ID</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="companyId" value="{{ d.params.companyId || '' }}" lay-verify="" placeholder="请输入公司ID" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div> -->

    <div class="layui-form-item">
        <label class="layui-form-label">控制板编号</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="ctrlId" value="{{ d.params.ctrlId || '' }}" lay-verify="" placeholder="请输入控制板编号" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">控制板硬件版本</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="ctrlHardwareVersion" value="{{ d.params.ctrlHardwareVersion || '' }}" lay-verify="" placeholder="请输入控制板硬件版本号" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">控制板软件版本</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="ctrlSoftwareVersion" id="date" value="{{ d.params.ctrlSoftwareVersion || '' }}" lay-verify="" placeholder="请输入控制板软件版本号" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">工控板硬件版本</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="hardwareVersion" value="{{ d.params.hardwareVersion || '' }}" lay-verify="" placeholder="请输入硬件版本" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">工控板软件版本</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="softwareVersion" value="{{ d.params.softwareVersion || '' }}" lay-verify="" placeholder="请输入软件版本" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <!-- <div class="layui-form-item">
        <label class="layui-form-label">添加时间</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="time" id='time' value="{{ d.params.time || '' }}" lay-verify="" placeholder="请输入添加时间" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div> -->
    <div class="layui-form-item">
        <label class="layui-form-label">交付时间</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="deliveryTime" id='deliveryTime' value="{{ d.params.deliveryTime || '' }}" lay-verify="" placeholder="请输入交付时间" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">小车状态</label>
        <div class="layui-input-block">
            <script type="text/html" template>
                <input type="radio" checked name="status" value="0" title="正常使用" {{ d.params.status===0 ? 'checked' : '' }}>
                <input type="radio" name="status" value="1" title="故障状态" {{ d.params.status===1 ? 'checked' : '' }}>
                <input type="radio" name="status" value="2" title="生命周期结束" {{ d.params.status===2 ? 'checked' : '' }}>
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <input type="button" lay-submit lay-filter="LAY-user-back-submit" value="确认" class="layui-btn">
        </div>
    </div>
</div>

<style type="text/css">
    .layui-form-label {
        width: 115px;
    }
</style>
<script>
    layui.use(['useradmin'], layui.factory('useradmin')).use(['admin', 'useradmin'], function() {
        var $ = layui.$,
            admin = layui.admin,
            setter = layui.setter,
            form = layui.form;
        var companyName = localStorage.getItem('companyName')
        var companyId = localStorage.getItem('companyId')
            admin.req({
                url: setter.request.baseUrl + "company/query",
                data: JSON.stringify({
                    pageNum: 1,
                    pageSize: 100
                }),
                type: "POST",
                dataType: "json",
                contentType: "application/json;charset=UTF-8",
                done: function(res) {
                    console.log(res);
                    if(companyName == 0){
                        var html = "<option style='color:#e6e6e6;'></option>";
                    for (i = 0; i < res.info.length; i++) {
                        if (res.info[i].companyName == null) {

                        } else {
                            html += "<option name='companyId'  value=" + res.info[i].id + ">" + res.info[i].companyName + "</option>"
                        }

                    }
                    console.log(html)
                    $("#sosoa").empty().append(html)
                    console.log($("#sosoa"))
                    form.render('select'); //需要渲染一下 
                    }else{
                        $("#sosoa").empty().append(`<option style='color:#e6e6e6;' value='${companyId}' selected="selected">${companyName}</option>`)
            console.log($("#sosoa"))
            form.render('select'); //需要渲染一下
                      
                    }
                    
                },

            });

    })
</script>